## index into the rows (spectra) -------------------------------------
## make some "spectra"
## numeric index
plot (flu, "spc", lines.args = list (lty = 2))
plot (flu[1:3], "spc", add = TRUE, col = "red") # select spectra
plot (flu[-(1:3)], "spc", add = TRUE, col = "blue") # delete spectra
## logic index
plot (flu, "spc", lines.args = list (lty = 2))
index <- rnorm (6) > 0
index
plot (flu[index], "spc", add = TRUE, col = "red") # select spectra
plot (flu[!index], "spc", add = TRUE, col = "blue") # select spectra
## index into the data columns ---------------------------------------
range (chondro[[,"x"]])
colnames (chondro[[,1]])
dim (chondro[[,c(TRUE, FALSE, FALSE)]])
chondro$x
## the shortcut functions --------------------------------------------
## extract the spectra matrix
flu[[]]
pca <- prcomp (flu[[]])
## extract the data.frame including the spectra matrix
flu$.
dim(flu$.)
colnames (flu$.)
flu$.$spc
calibration <- lm (spc ~ c, data = flu[,,450]$.)
calibration
flu$..
colnames (flu$..)
## replacement functions
spc <- flu
spc$.
spc[, "c"] <- 16 : 11
spc$.
spc$z <- 1 : 6
spc
spc$z <- list (1 : 6, "z / a.u.")
## be careful:
plot (spc)
spc[] <- 6 : 1
spc$..
plot (spc)
spc[[]]
spc[[3]] <- -spc[[3]]
spc[[]]
spc[[,,405 : 410]] <- -spc[[,,405 : 410]]
spc[[]]
Run the code above in your browser using DataLab